package com.zipking.cloud.springbootmybatis.zh;

import java.util.ArrayList;
import java.util.List;
//容器节点（部门）
public class Department extends OrganizationComponent {

    private List<OrganizationComponent> subComponents = new ArrayList<>();

    public Department(String name, String description) {
        super(name, description);
    }

    public void addComponent(OrganizationComponent component) {
        subComponents.add(component);
    }

    public void removeComponent(OrganizationComponent component) {
        subComponents.remove(component);
    }

    @Override
    protected void print() {
        System.out.println("- " + getName() + "(" + getDescription() + ")");

        for (OrganizationComponent component : subComponents) {
            component.print();
        }
    }
}
